<!--
 * @Description: 
 * @Author: shizhe
 * @Date: 2022-03-07 09:34:32
 * @LastEditTime: 2022-03-07 11:09:22
 * @LastEditors: shizhe
 * @Reference: 
-->
<template>
  <div id="billingreview">
    <div class="list-container">
      <div class="tables">
        <el-table
          :data="tableData"
          class="table"
          height="100%"
          ref="jdjgTable"
          @sort-change="sortChange"
          :header-cell-style="{
            padding: '0px',
            background: 'linear-gradient(0deg, #F4F6F9, #EAECF4, #F3F6F9)'
          }"
          :row-class-name="tabRowClassName"
          header-row-class-name="mapTable_th"
        >
          <el-table-column width="60" align="center" type="index" :index="addIndex" label="序号">
            <el-table-column width="60" align="center" type="index" label="检索"> </el-table-column>
          </el-table-column>
          <el-table-column label="户名" align="center" width="180">
            <el-table-column width="180" align="center" sortable="custom" prop="accountName">
              <template slot="header" align="center" slot-scope="{}">
                <div class="searchBox" @click.stop>
                  <el-input v-model.trim="searchPositionName" @change="getDataChange"></el-input>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="开户银行" align="center" width="180">
            <el-table-column width="180" align="center" sortable="custom" prop="bankName">
              <template slot="header" align="center" slot-scope="{}">
                <div class="searchBox" @click.stop>
                  <el-input v-model.trim="searchPositionName" @change="getDataChange"></el-input>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="银行账号" align="center" width="180">
            <el-table-column width="180" align="center" sortable="custom" prop="bankAccount">
              <template slot="header" align="center" slot-scope="{}">
                <div class="searchBox" @click.stop>
                  <el-input v-model.trim="searchPositionName" @change="getDataChange"></el-input>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="联系方式" align="center" width="180">
            <el-table-column width="180" align="center" sortable="custom" prop="phone">
              <template slot="header" align="center" slot-scope="{}">
                <div class="searchBox" @click.stop>
                  <el-input v-model.trim="searchPositionName" @change="getDataChange"></el-input>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="状态" align="center">
            <el-table-column align="center" prop="state">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.state == 1 ? '绑定中' : '已完成' }}
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="操作" align="center" fixed="right">
            <el-table-column align="center">
              <template slot-scope="scope">
                <div class="" v-if="scope.row.state == 1">
                  <el-button type="text" class="ty czBtn" size="small" @click="handleClick(scope.row)">
                    撤销
                  </el-button>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="pags">
      <element-pagination @getData="getPagChange" :Total="total"> </element-pagination>
    </div>
  </div>
</template>

<script>
import ElementPagination from '../../../../components/ElementPagination.vue'
export default {
  name: 'accountOpenReview',
  data() {
    return {
      tableData: [],
      total: 0,
      page: 1,
      size: 15,
      searchPositionName: ''
    }
  },
  components: {
    ElementPagination
  },
  mounted() {
    this.getData()
  },
  methods: {
    handleClick(scope) {
      this.$confirm('是否为该用户撤销绑定', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$https({
          method: 'post',
          url: '/government/deleteBankAccountById?bankId=' + scope.id
        })
          .then(res => {
            if (res.code == 0) {
              this.getData()
              this.$message.success(res.msg)
            } else {
              this.$message.error(res.msg)
            }
          })
          .catch(err => {
            console.log(err)
          })
      })
    },
    getData() {
      this.$https({
        method: 'post',
        url: '/government/listAllBankAccountPage',
        data: {
          page: this.page,
          size: this.size
        }
      })
        .then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records || []
            this.total = res.data.total || 0
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    getDataChange() {},
    getPagChange(data) {
      this.page = data.currentPage
      this.size = data.pagesize
      this.getData()
    },
    sortChange() {},
    addIndex(index) {
      return index + 1 + (this.page - 1) * this.size
    },
    tabRowClassName({ row, rowIndex }) {
      let index = rowIndex + 1
      if (index % 2 == 0) {
        return 'warning-row'
      }
    }
  }
}
</script>
<style lang="less" scoped>
#billingreview {
  height: 100%;
  .list-container {
    height: calc(100% - 62px);
    .tables {
      height: 100%;
    }
  }
  .sc,
  .ty {
    color: #ff3d3d;
  }
}
</style>
